<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center InterestsPage_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub InterestsPage_fd0_0'>
          <view class='flex flex-wrap align-center InterestsPage_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  InterestsPage_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='InterestsPage_fd0_0_c1_c0'>兴趣爱好</text>
          </view>
          <view class='flex flex-wrap align-center justify-end InterestsPage_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout InterestsPage_flex_1">
        <view class='flex flex-wrap align-center InterestsPage_fd1_0'>
          <text class='InterestsPage_fd1_0_c0'>你喜欢什么（{{chooseNum}}/{{hobbyType.length}}）</text>
        </view>
        <view class='flex flex-wrap align-center'>
          <view class="" v-for="(item,index) in hobbyType" :key="index" @click="choosetype(item)">
            <view v-if="!item.check" class="InterestsPage_fd1_1_c0_c1">{{item.title}}
            </view>
            <view v-else class="InterestsPage_fd1_1_c0_c1_s">
              {{item.title}}
            </view>
          </view>
          <!-- <benben-select-diy ref="showSelectPopup1703927930895" class-name='flex align-center flex'
            :items.sync="hobbyType" v-model="hobby_id" default-type="aid" default-label="title" :allow-cancel='true'
            :chooseNum.sync='chooseNum' type="checkbox" :disabled='false'>
            <template v-for='(item,key0) in hobbyType'>
              <view v-if="item.isSelected" class='flex align-center justify-center flex InterestsPage_fd1_1_c0_c0'
                :key="key0" @tap="$refs.showSelectPopup1703927930895.tapHandle(key0)">
                <text class='InterestsPage_fd1_1_c0_c0_c0'>{{item.title}}</text>
              </view>
              <view v-else class='flex align-center justify-center flex InterestsPage_fd1_1_c0_c1' :key="key0"
                @tap="$refs.showSelectPopup1703927930895.tapHandle(key0)">
                <text class='InterestsPage_fd1_1_c0_c1_c0'>{{item.title}}</text>
              </view>
            </template></benben-select-diy> -->
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <view class="flex flex-wrap align-start justify-center benben-position-layout flex InterestsPage_flex_2"
        @click="submit">
        <button class='InterestsPage_fd2_0'>完成</button>

      </view>
      <view :style="{height: '170rpx'}"></view>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        "hobbyType": [],
        chooseNum: 0,
        hobby_id: ''
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.hobby_id = options.hobby_id
      this.getLabelFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      choosetype(item) {
        item.check = !item.check
      },
      submit() {
        let arr1 = this.hobbyType.filter(item => item.check)

        if (arr1.length > 5) {

          this.$message.info('请选择最多五个个人兴趣爱好')
          return;
        }

        this.hobby_id = arr1.map(itemC => {
          return itemC.aid
        }).join(',')
        if (!this.hobby_id) {
          this.$message.info('请选择个人兴趣爱好')
          return;
        }
        this.$api.post(global.apiUrls.post5cb54af125f1c, {
          userlable_id: this.hobby_id
        }).then(res => {
          if (res.data.code == 1) {
            uni.navigateBack()
          }
        })
      },
      //获取标签
      async getLabelFunc() {
        //请求方法
        //数据验证

        let datahobbyType = await this.$api.post(global.apiUrls.post657ac48751d25, {
          ids: this.hobby_id
        });

        if (datahobbyType.data.code != 1) {
          this.$message.info(datahobbyType.data.msg);
          return
        }
        let infohobbyType = datahobbyType.data.data;
        this.hobbyType = infohobbyType.data

      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .InterestsPage_flex_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .InterestsPage_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .InterestsPage_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .InterestsPage_fd0_0_c0 {
    width: 120rpx;
  }

  .InterestsPage_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .InterestsPage_flex_1 {
    padding: 22rpx 44rpx 0rpx 32rpx;
  }

  .InterestsPage_fd1_1_c0_c1_c0 {
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 28rpx;
  }

  .InterestsPage_fd1_1_c0_c1 {
    background: rgba(248, 248, 248, 1);
    width: 120rpx;
    height: 64rpx;
    border-radius: 12rpx;
    background-size: 100% auto;
    margin: 0rpx 16rpx 16rpx 0rpx;
    text-align: center;
    line-height: 64rpx;
  }

  .InterestsPage_fd1_1_c0_c0_c0 {
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    color: #6450EB;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 28rpx;
  }

  .InterestsPage_fd1_1_c0_c1_s {
    border: 1px solid rgba(100, 80, 235, 1);
    background: rgba(100, 80, 235, 0.08);
    width: 120rpx;
    height: 64rpx;
    border-radius: 12rpx;
    background-size: 100% auto;
    margin: 0rpx 16rpx 16rpx 0rpx;
    color: #6450EB;
    text-align: center;
    line-height: 64rpx;
  }

  .InterestsPage_fd1_1_c0_c0 {}

  .InterestsPage_fd1_0_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 700;
    line-height: 32rpx;
  }

  .InterestsPage_fd1_0 {
    margin: 0rpx 0rpx 24rpx 0rpx;
  }

  .InterestsPage_flex_2 {
    background: rgba(255, 255, 255, 1);
    width: 750rpx;
    height: 170rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
    background-size: 100% auto;
  }

  .InterestsPage_fd2_0 {
    background: rgba(100, 80, 235, 1);
    border-radius: 44rpx;
    width: 686rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
    margin: 20rpx 0rpx 0rpx 0rpx;
  }
</style>
